﻿@using BLL.Services.Categories
@{
    var categories = DependencyResolver.Current
        .GetService<ICategoriesService>()
        .GetAllCategories.Select(x => new SelectListItem()
                                                    {
                                                        Text = x.Name,
                                                        Value = x.CategoryId.ToString()
                                                    }).OrderBy(x => x.Text); }
<select Id="Categories" class="multiselect" multiple="multiple" name="Categories">
    @foreach(var item in categories)
    {
        <option @Html.Raw(string.Format("<%=_.lastIndexOf(Categories, {0})>=0?'selected=\"selected\"':''%> value=\"{0}\"",item.Value) )>@item.Text</option>
    }
</select>
